<?php

/**
 * @version		$Id: tablecollation.php $
 * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_BASE') or die;

jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

/**
 * Component Field class for the Joomla Framework.
 *
 * @package		Joomla.Administrator
 * @subpackage	com_gencode
 * @since		1.6
 */
class JFormFieldTableCollation extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var		string
	 * @since	1.6
	 */
	protected $type = 'TableCollation';
	
	public function getInput($name = null, $val = null)
	{
		if(!$name)
			$name = $this->name;
		
		$html  = '<select name="'.$name.'">' . "\n";
		$html .= '<option value=""></option>';
		
		$options = TableOptionsHelper::collation();
		
		foreach ($options as $optGroup => $opt)
		{
			$html .= '<optgroup label="'.$optGroup.'" style="font-size: 11px;">' . "\n";
			
			foreach ($opt as $option)
			{
				$selected = ($val == $option) ? 'selected="selected"' : null;
				
				$html .= '<option value="'.$option.'" '.$selected.'>'.$option.'</option>' . "\n";
			}
			
			$html .= '</optgroup>' . "\n";
		}
		
		$html .= '</select>' . "\n";
		
		return $html;
	}
	
	
}